USE [ServerMonitor]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SendLogFileAlertMail]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[SendLogFileAlertMail]
GO
USE [ServerMonitor]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[SendLogFileAlertMail] @recipients VARCHAR(MAX)
AS
BEGIN
  IF(EXISTS(SELECT * FROM [msdb].[dbo].[sysmail_profile]))
  BEGIN
    DECLARE @Html NVARCHAR(MAX)
    SET @Html = [ServerMonitor].[dbo].[LogFileAlertReportHtml]()
    
    EXEC [msdb].[dbo].[sp_send_dbmail] 
    @profile_name = 'SQLServerMailProfile',
    @recipients=@recipients,
    @copy_recipients = NULL,
    @subject = 'Log File Alert Report',
    @body = @Html,
    @body_format = 'HTML' ;
  END
END



GO


